fix(markdown-preview): improve rendering and asset handling#1966
Merged
bajrangCoder merged 16 commits intoAcode-Foundation:mainfrom Mar 21, 2026
Merged
Conversation
Contributor
Greptile SummaryThis PR introduces a fully rewritten in-app markdown preview for Acode, replacing the previous server-based approach. It adds support for footnotes, task lists, emojis, mermaid diagrams, anchor links, math (KaTeX), syntax highlighting, and local asset resolution — all rendered inline within the app using a new Key highlights of the implementation:
Two new issues found beyond those already discussed in previous threads:
Confidence Score: 2/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant U as User (opens .md)
participant R as run.js
participant P as openMarkdownPreview
participant C as createMarkdownPreview
participant RD as renderer.js
participant M as mermaid (lazy)
participant K as katex/texmath (lazy)
U->>R: run() called
R->>R: check .md extension
R->>P: openMarkdownPreview(file)
P->>C: createMarkdownPreview(file) (first time)
C->>C: bind(file)
C->>RD: renderMarkdown(text, file)
RD->>RD: hasMathContent(text)?
alt has math
RD->>K: import("katex") + import("markdown-it-texmath")
K-->>RD: modules resolved
RD->>RD: createMarkdownIt({ katex, texmath })
else no math
RD->>RD: use baseMarkdownIt
end
RD-->>C: { html }
C->>C: DOMPurify.sanitize(html)
C->>C: resolveRenderedImages()
C->>C: enhanceCodeBlocks() → DOMPurify(highlighted)
C->>C: renderMermaidBlocks()
C->>M: import("mermaid") (lazy)
M-->>C: mermaid module
C->>M: mermaid.render(id, source)
M-->>C: { svg, bindFunctions }
C->>C: DOMPurify.sanitize(svg, SVG profile)
C->>C: block.innerHTML = sanitizedSvg
C->>C: bindFunctions?.(block)
Last reviewed commit: "fix" |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as outdated.
This comment was marked as outdated.
Added lazy loading for KaTeX and markdown-it-texmath modules.
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #1355